package 包装类;

import java.util.Scanner;

public class newScanner1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Integer:请输入：");
        String s = sc.nextLine();
        //需要什么类型的数据就调用什么数据类型的包装类
        //parseInt: 将字符串转换为int整形
        int i = Integer.parseInt(s);
        System.out.println(i);
        int a = 1;
        System.out.println(a+i);

        System.out.println("-------------");

        //将字符串转换为布尔类型，输入“true”即输出“true”，输入“false“或者其他符号均为“false”
        System.out.println("Boolean:请输入：");
        String s1 = sc.nextLine();
        boolean b = Boolean.parseBoolean(s1);
        System.out.println(b);

        System.out.println("-------------");

        //将字符串转换为浮点型
        System.out.println("Float:请输入：");
        String s2 = sc.nextLine();
        float v = Float.parseFloat(s2);
        float b1 = 1.1F;
        int b2 = 2;
        System.out.println(v+b1);
        System.out.println(v+b2);
    }
}
